// 检测碰撞的相关函数
export function collision(pos) {
  if (collisionBorder(pos)) {
    return 8;
  } else if (collisionSoftWall(pos)) {
    return 1;
  } else if (collisionHardWall(pos)) {
    return 2;
  } else if (collisionHome(pos)) {
    return 3;
  } else if (collisionAutoTank(pos)) {
    return 4;
  } else if (collisionMyTank(pos)) {
    return 5;
  } else if (collisionMyBullet(pos)) {
    return 6;
  } else if (collisionBullet(pos)) {
    return 7;
  } else {
    return 0;
  }
}

//碰撞边界检测
export function collisionBorder(pos) {
  return pos[0] < 0 || pos[0] > 13 || pos[1] < 0 || pos[1] > 19;

}

// 碰到可击毁墙检测
export function collisionSoftWall(pos) {
  return getApp().data.mapSource[pos[0]][pos[1]] === 1;

}

// 碰到不可击毁墙检测
export function collisionHardWall(pos) {
  return getApp().data.mapSource[pos[0]][pos[1]] === 2;

}

// 碰到家检测
export function collisionHome(pos) {
  return getApp().data.mapSource[pos[0]][pos[1]] === 3;

}

// 碰到敌方坦克检测
export function collisionAutoTank(pos) {
  return getApp().data.mapSource[pos[0]][pos[1]] === 4;

}

// 碰到玩家坦克检测
export function collisionMyTank(pos) {
  return getApp().data.mapSource[pos[0]][pos[1]] === 5;

}

// 碰到子弹检测
export function collisionMyBullet(pos) {   //6代表是我的子弹
  return getApp().data.mapSource[pos[0]][pos[1]] === 6;

}

// 碰到敌方子弹检测
export function collisionBullet(pos) {
  return getApp().data.mapSource[pos[0]][pos[1]] === 7;

}